package com.card.hwatt.service.impt;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.card.hwatt.dao.BaseDao;
import com.card.hwatt.service.BaseService;
import com.card.hwatt.dto.PageParam;
import com.card.hwatt.dto.PageResult;

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public abstract class BaseServiceImpt<T> implements BaseService<T> {

	protected abstract BaseDao<T> getDao();

	@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
	@Override
	public Object uniqueResult(String hql, Object... agrs) {
		return getDao().uniqueResult(hql, agrs);
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
	@Override
	public List<T> loadAll() {
		return getDao().loadAll();
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
	@Override
	public PageResult<T> loadAll(PageParam param) {
		return getDao().loadAll(param);
	}

	@Override
	public T get(Serializable id) {
		return getDao().get(id);
	}

	@Override
	public void save(T entity) {
		getDao().save(entity);
	}

	@Override
	public void update(T entity) {
		getDao().update(entity);
	}

	@Override
	public void delete(Serializable id) {
		getDao().delete(id);
	}
}
